<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_address', function (Blueprint $table) {
            $table->id();
            $table->integer('user_id')->default(0)->comment('用户ID');
            $table->string('name',15)->default('')->comment('收货人');
            $table->char('mobile',11)->index()->default('')->comment('手机号');
            $table->string('address',255)->default('')->comment('完整地址');

            $table->integer('province_id')->default(0)->unsigned()->comment('省id');
            $table->integer('city_id')->default(0)->unsigned()->comment('市id');
            $table->integer('area_id')->default(0)->unsigned()->comment('区（县）id');
            $table->string('province',20)->default('')->comment('省');
            $table->string('city',20)->default('')->comment('市');
            $table->string('area',20)->default('')->comment('区（县）');
            $table->string('detail_address',255)->default('')->comment('详细地址');

            $table->tinyInteger('is_default')->default(0)->comment('是否默认:1=是,0=否');

            $table->tinyInteger('status')->default(0)->comment('状态:1=正常,2=禁用');
            $table->tinyInteger('is_delete')->default(0)->comment('是否删除:1=删除,0=正常');
            $table->integer('created_at')->default(0)->comment('创建时间');
            $table->integer('updated_at')->default(0)->comment('修改时间');
        });
        DB::statement("ALTER TABLE `user_address` comment '【用户】收货地址'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_address');
    }
};
